#include<bits/stdc++.h>
using namespace std;
int n, m, q;
const int maxn = 1006;
long long  a[maxn][maxn], diff[maxn][maxn];
int main() {
  cin>>n>>m>>q;
  for(int i=1; i<=n; ++i) {
    for(int j=1; j<=m; ++j) {
      cin>>a[i][j];
    }
  }
  while(q--) {
    int x1, y1, x2, y2, c;
    cin>>x1>>y1>>x2>>y2>>c;
    diff[x2+1][y2+1] += c;
    diff[x1][y2+1] -=c;
    diff[x2+1][y1] -=c;
    diff[x1][y1] += c;
  }
  for(int i=1; i<=n; ++i)
    for(int j=1; j<=m; ++j) {
      diff[i][j] += diff[i-1][j] + diff[i][j-1] - diff[i-1][j-1];
    }
  for(int i=1; i<=n; ++i) {
    for(int j=1; j<=m; ++j) {
      cout<<a[i][j] + diff[i][j] << ' ';
    }
    cout<<'\n';
  }
}
